using System;
using System.Collections.Generic;
using System.Text;

namespace PicAFlick.Domain
{
    public abstract class Folder
    {
        private List<ImageDetails> _images = new List<ImageDetails>();
        private Folder _parentFolder;
        private string _name;
        private List<Folder> _subFolders = new List<Folder>();

        public List<Folder> SubFolders
        {
            get { return _subFolders; }
            set { _subFolders = value; }
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public Folder ParentFolder
        {
            get { return _parentFolder; }
            set { _parentFolder = value; }
        }

        public List<ImageDetails> Images
        {
            get { return _images; }
            set { _images = value; }
        }


        protected abstract void Populate();

        public void SortImageByFileSize()
        {
            _images.Sort(new Comparison<ImageDetails>( delegate(ImageDetails d1, ImageDetails d2){
                int ret = 0;
                if (d1.FileSize == d2.FileSize)
                {
                    ret = 0;
                }
                else if (d1.FileSize < d2.FileSize)
                {
                    ret = 1;
                }
                else
                {
                    ret = -1;
                }
                
                return ret;
            
            }));
        }

        public abstract System.IO.Stream GetImageStream(string p);
    }
}
